Skip to main content

protobuf 报错

错误提示 protoc-gen-go: unable to determine Go import path for "test.proto"

D:\go_project\leafserver\src\server\msg>protoc --go_out=. test.proto
protoc-gen-go: unable to determine Go import path for "test.proto"

Please specify either:
• a "go_package" option in the .proto source file, or
• a "M" argument on the command line.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

--go_out: protoc-gen-go: Plugin failed with status code 1.

proto文件修改为

syntax = "proto3";
option go_package = "../msg";

message Hello {
string name = 1;
}

执行

protoc --go_out=. test.proto